<!DOCTYPE html>
<html>
<head>
    

    

    



    <meta charset="utf-8">
    
    
    
    <title>学习 ES6，一篇文章就够了 | Xiaoming&#39;s Blog | 一入前端深似海，从此妹子是路人。</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    
    <meta name="theme-color" content="#3F51B5">
    
    
    <meta name="keywords" content="JavaScript,js,ECMAScript 6,es6">
    <meta name="description" content="ES6 简介ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaScript 语言可以用来编写复杂的大型应用程序，成为企业级开发语言。 ECMAScript 和 JavaScript 的关系：前者是后者的语法规格，后者是前者的一种实现 Babel：将ES6代码转为ES5代码 http://babeljs.io/">
<meta name="keywords" content="JavaScript,js,ECMAScript 6,es6">
<meta property="og:type" content="article">
<meta property="og:title" content="学习 ES6，一篇文章就够了">
<meta property="og:url" content="http://www.lovebxm.com/2017/06/24/es6_study/index.html">
<meta property="og:site_name" content="Xiaoming&#39;s Blog">
<meta property="og:description" content="ES6 简介ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaScript 语言可以用来编写复杂的大型应用程序，成为企业级开发语言。 ECMAScript 和 JavaScript 的关系：前者是后者的语法规格，后者是前者的一种实现 Babel：将ES6代码转为ES5代码 http://babeljs.io/">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1504317-805392e6d4ad6f43.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2017-06-24T10:52:48.965Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="学习 ES6，一篇文章就够了">
<meta name="twitter:description" content="ES6 简介ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaScript 语言可以用来编写复杂的大型应用程序，成为企业级开发语言。 ECMAScript 和 JavaScript 的关系：前者是后者的语法规格，后者是前者的一种实现 Babel：将ES6代码转为ES5代码 http://babeljs.io/">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/1504317-805392e6d4ad6f43.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
    
        <link rel="alternate" type="application/atom+xml" title="Xiaoming&#39;s Blog" href="/atom.xml">
    
    <link rel="shortcut icon" href="/favicon.ico">
    <link rel="stylesheet" href="//unpkg.com/hexo-theme-material-indigo@latest/css/style.css">
    <script>window.lazyScripts=[]</script>
</head>

<body>
    <div id="loading" class="active"></div>

    <aside id="menu"  >
  <div class="inner flex-row-vertical">
    <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menu-off">
        <i class="icon icon-lg icon-close"></i>
    </a>
    <div class="brand-wrap" style="background-image:url(/img/brand.jpg)">
      <div class="brand">
        <a href="/" class="avatar waves-effect waves-circle waves-light">
          <img src="/img/avatar.jpg">
        </a>
        <hgroup class="introduce">
          <h5 class="nickname">白小明</h5>
          <a href="mailto:80583600@qq.com" title="80583600@qq.com" class="mail">80583600@qq.com</a>
        </hgroup>
      </div>
    </div>
    <div class="scroll-wrap flex-col">
      <ul class="nav">
        
            <li class="waves-block waves-effect">
              <a href="/"  >
                <i class="icon icon-lg icon-home"></i>
                主页
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/tags"  >
                <i class="icon icon-lg icon-tags"></i>
                标签
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/hand-peace-o"  >
                <i class="icon icon-lg icon-hand-peace-o"></i>
                作品
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="https://github.com/bxm0927" target="_blank" >
                <i class="icon icon-lg icon-github"></i>
                Github
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/user"  >
                <i class="icon icon-lg icon-user"></i>
                关于我
              </a>
            </li>
        
            <li class="waves-block waves-effect">
              <a href="/404.html"  >
                <i class="icon icon-lg icon-link"></i>
                404 测试
              </a>
            </li>
        
      </ul>
    </div>
  </div>
</aside>

    <main id="main">
        <header class="top-header" id="header">
    <div class="flex-row">
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light on" id="menu-toggle">
          <i class="icon icon-lg icon-navicon"></i>
        </a>
        <div class="flex-col header-title ellipsis">学习 ES6，一篇文章就够了</div>
        
        <div class="search-wrap" id="search-wrap">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="back">
                <i class="icon icon-lg icon-chevron-left"></i>
            </a>
            <input type="text" id="key" class="search-input" autocomplete="off" placeholder="输入感兴趣的关键字">
            <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="search">
                <i class="icon icon-lg icon-search"></i>
            </a>
        </div>
        
        
        <a href="javascript:;" class="header-icon waves-effect waves-circle waves-light" id="menuShare">
            <i class="icon icon-lg icon-share-alt"></i>
        </a>
        
    </div>
</header>
<header class="content-header post-header">

    <div class="container fade-scale">
        <h1 class="title">学习 ES6，一篇文章就够了</h1>
        <h5 class="subtitle">
            
                <time datetime="2017-06-24T10:51:10.191Z" itemprop="datePublished" class="page-time">
  2017-06-24
</time>


            
        </h5>
    </div>

    


</header>


<div class="container body-wrap">
    
    <aside class="post-widget">
        <nav class="post-toc-wrap" id="post-toc">
            <h4>TOC</h4>
            <ol class="post-toc"><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#ES6-简介"><span class="post-toc-number">1.</span> <span class="post-toc-text">ES6 简介</span></a></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#新特性"><span class="post-toc-number">2.</span> <span class="post-toc-text">新特性</span></a><ol class="post-toc-child"><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#let、const"><span class="post-toc-number">2.1.</span> <span class="post-toc-text">let、const</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#import、export"><span class="post-toc-number">2.2.</span> <span class="post-toc-text">import、export</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#class、extends、super"><span class="post-toc-number">2.3.</span> <span class="post-toc-text">class、extends、super</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#arrow-functions-（箭头函数）"><span class="post-toc-number">2.4.</span> <span class="post-toc-text">arrow functions （箭头函数）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#template-string-（模板字符串）"><span class="post-toc-number">2.5.</span> <span class="post-toc-text">template string （模板字符串）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#destructuring-（解构）"><span class="post-toc-number">2.6.</span> <span class="post-toc-text">destructuring （解构）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#default-函数默认参数"><span class="post-toc-number">2.7.</span> <span class="post-toc-text">default 函数默认参数</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#rest-arguments-（rest参数）"><span class="post-toc-number">2.8.</span> <span class="post-toc-text">rest arguments （rest参数）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Spread-Operator-（展开运算符）"><span class="post-toc-number">2.9.</span> <span class="post-toc-text">Spread Operator （展开运算符）</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#对象"><span class="post-toc-number">2.10.</span> <span class="post-toc-text">对象</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Promise"><span class="post-toc-number">2.11.</span> <span class="post-toc-text">Promise</span></a></li><li class="post-toc-item post-toc-level-3"><a class="post-toc-link" href="#Generators"><span class="post-toc-number">2.12.</span> <span class="post-toc-text">Generators</span></a></li></ol></li><li class="post-toc-item post-toc-level-2"><a class="post-toc-link" href="#总结"><span class="post-toc-number">3.</span> <span class="post-toc-text">总结</span></a></li></ol>
        </nav>
    </aside>
    
<article id="post-es6_study"
  class="post-article article-type-post fade" itemprop="blogPost">

    <div class="post-card">
        <h1 class="post-card-title">学习 ES6，一篇文章就够了</h1>
        <div class="post-meta">
            <time class="post-time" title="2017-06-24 18:51:10" datetime="2017-06-24T10:51:10.191Z"  itemprop="datePublished">2017-06-24</time>

            


            
<span id="busuanzi_container_page_pv" title="文章总阅读量" style='display:none'>
    <i class="icon icon-eye icon-pr"></i><span id="busuanzi_value_page_pv"></span>
</span>


            

        </div>
        <div class="post-content" id="post-content" itemprop="postContent">
            <h2 id="ES6-简介"><a href="#ES6-简介" class="headerlink" title="ES6 简介"></a>ES6 简介</h2><p>ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaScript 语言可以用来编写复杂的大型应用程序，成为企业级开发语言。</p>
<p><strong>ECMAScript 和 JavaScript 的关系</strong>：前者是后者的语法规格，后者是前者的一种实现</p>
<p><strong>Babel</strong>：将ES6代码转为ES5代码 <a href="http://babeljs.io/" target="_blank" rel="external">http://babeljs.io/</a></p>
<figure class="image-bubble">
                <div class="img-lightbox">
                    <div class="overlay"></div>
                    <img src="http://upload-images.jianshu.io/upload_images/1504317-805392e6d4ad6f43.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="image" title="">
                </div>
                <div class="image-caption">image</div>
            </figure>
<a id="more"></a>
<h2 id="新特性"><a href="#新特性" class="headerlink" title="新特性"></a>新特性</h2><h3 id="let、const"><a href="#let、const" class="headerlink" title="let、const"></a>let、const</h3><p><strong>let 定义的变量不会被变量提升，const 定义的常量不能被修改，let 和 const 都是块级作用域</strong></p>
<p>ES6前，js 是没有块级作用域 {} 的概念的。（有函数作用域、全局作用域、eval作用域）</p>
<p>ES6后，let 和 const 的出现，js 也有了块级作用域的概念，前端的知识是日新月异的~</p>
<p>变量提升：在ES6以前，var关键字声明变量。无论声明在何处，都会被视为声明在函数的最顶部；不在函数内即在全局作用域的最顶部。这样就会引起一些误解。例如：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">console.log(a);  // undefined</div><div class="line">var a = &apos;hello&apos;;</div><div class="line"></div><div class="line"># 上面的代码相当于</div><div class="line">var a;</div><div class="line">console.log(a);</div><div class="line">a = &apos;hello&apos;;</div><div class="line"></div><div class="line"># 而 let 就不会被变量提升</div><div class="line">console.log(a); // a is not defined</div><div class="line">let a = &apos;hello&apos;;</div></pre></td></tr></table></figure>
<p>const 定义的常量不能被修改</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">var name = &quot;bai&quot;;</div><div class="line">name = &quot;ming&quot;;</div><div class="line">console.log(name); // ming</div><div class="line"></div><div class="line"></div><div class="line">const name = &quot;bai&quot;;</div><div class="line">name = &quot;ming&quot;; // Assignment to constant variable.</div><div class="line">console.log(name);</div></pre></td></tr></table></figure>
<h3 id="import、export"><a href="#import、export" class="headerlink" title="import、export"></a>import、export</h3><p><strong>import导入模块、export导出模块</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">// 全部导入</div><div class="line">import people from &apos;./example&apos;</div><div class="line"></div><div class="line">// 将整个模块当作单一对象进行导入，该模块的所有导出都会作为对象的属性存在</div><div class="line">import * as example from &quot;./example.js&quot;</div><div class="line">console.log(example.name)</div><div class="line">console.log(example.getName())</div><div class="line"></div><div class="line">// 导入部分，引入非 default 时，使用花括号</div><div class="line">import &#123;name, age&#125; from &apos;./example&apos;</div><div class="line"></div><div class="line"></div><div class="line">// 导出默认, 有且只有一个默认</div><div class="line">export default App</div><div class="line"></div><div class="line">// 部分导出</div><div class="line">export class App extend Component &#123;&#125;;</div></pre></td></tr></table></figure>
<h3 id="class、extends、super"><a href="#class、extends、super" class="headerlink" title="class、extends、super"></a>class、extends、super</h3><p>ES5中最令人头疼的的几个部分：原型、构造函数，继承，有了ES6我们不再烦恼！</p>
<p>ES6引入了Class（类）这个概念。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div></pre></td><td class="code"><pre><div class="line">class Animal &#123;</div><div class="line">    constructor() &#123;</div><div class="line">        this.type = &apos;animal&apos;;</div><div class="line">    &#125;</div><div class="line">    says(say) &#123;</div><div class="line">        console.log(this.type + &apos; says &apos; + say);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">let animal = new Animal();</div><div class="line">animal.says(&apos;hello&apos;); //animal says hello</div><div class="line"></div><div class="line">class Cat extends Animal &#123;</div><div class="line">    constructor() &#123;</div><div class="line">        super();</div><div class="line">        this.type = &apos;cat&apos;;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">let cat = new Cat();</div><div class="line">cat.says(&apos;hello&apos;); //cat says hello</div></pre></td></tr></table></figure>
<p>上面代码首先用class定义了一个“类”，可以看到里面有一个constructor方法，这就是构造方法，而this关键字则代表实例对象。简单地说，constructor内定义的方法和属性是实例对象自己的，而constructor外定义的方法和属性则是所有实力对象可以共享的。</p>
<p>Class之间可以通过extends关键字实现继承，这比ES5的通过修改原型链实现继承，要清晰和方便很多。上面定义了一个Cat类，该类通过extends关键字，继承了Animal类的所有属性和方法。</p>
<p>super关键字，它指代父类的实例（即父类的this对象）。子类必须在constructor方法中调用super方法，否则新建实例时会报错。这是因为子类没有自己的this对象，而是继承父类的this对象，然后对其进行加工。如果不调用super方法，子类就得不到this对象。</p>
<p>ES6的继承机制，实质是先创造父类的实例对象this（所以必须先调用super方法），然后再用子类的构造函数修改this。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div></pre></td><td class="code"><pre><div class="line">// ES5</div><div class="line">var Shape = function(id, x, y) &#123;</div><div class="line">    this.id = id,</div><div class="line">        this.move(x, y);</div><div class="line">&#125;;</div><div class="line">Shape.prototype.move = function(x, y) &#123;</div><div class="line">    this.x = x;</div><div class="line">    this.y = y;</div><div class="line">&#125;;</div><div class="line"></div><div class="line">var Rectangle = function id(ix, x, y, width, height) &#123;</div><div class="line">    Shape.call(this, id, x, y);</div><div class="line">    this.width = width;</div><div class="line">    this.height = height;</div><div class="line">&#125;;</div><div class="line">Rectangle.prototype = Object.create(Shape.prototype);</div><div class="line">Rectangle.prototype.constructor = Rectangle;</div><div class="line"></div><div class="line">var Circle = function(id, x, y, radius) &#123;</div><div class="line">    Shape.call(this, id, x, y);</div><div class="line">    this.radius = radius;</div><div class="line">&#125;;</div><div class="line">Circle.prototype = Object.create(Shape.prototype);</div><div class="line">Circle.prototype.constructor = Circle;</div><div class="line"></div><div class="line">// ES6</div><div class="line">class Shape &#123;</div><div class="line">    constructor(id, x, y) &#123;</div><div class="line">        this.id = id this.move(x, y);</div><div class="line">    &#125;</div><div class="line">    move(x, y) &#123;</div><div class="line">        this.x = x this.y = y;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">class Rectangle extends Shape &#123;</div><div class="line">    constructor(id, x, y, width, height) &#123;</div><div class="line">        super(id, x, y) this.width = width this.height = height;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">class Circle extends Shape &#123;</div><div class="line">    constructor(id, x, y, radius) &#123;</div><div class="line">        super(id, x, y) this.radius = radius;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="arrow-functions-（箭头函数）"><a href="#arrow-functions-（箭头函数）" class="headerlink" title="arrow functions （箭头函数）"></a>arrow functions （箭头函数）</h3><p>函数的快捷写法。不需要 function 关键字来创建函数，省略 return 关键字，继承当前上下文的 this 关键字</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">// ES5</div><div class="line">var arr1 = [1, 2, 3];</div><div class="line">var newArr1 = arr1.map(function(x) &#123;</div><div class="line">  return x + 1;</div><div class="line">&#125;);</div><div class="line"></div><div class="line">// ES6</div><div class="line">let arr2 = [1, 2, 3];</div><div class="line">let newArr2 = arr2.map((x) =&gt; &#123;</div><div class="line">  x + 1</div><div class="line">&#125;);</div></pre></td></tr></table></figure>
<p>箭头函数小细节：当你的函数有且仅有一个参数的时候，是可以省略掉括号的；当你函数中有且仅有一个表达式的时候可以省略{}</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">let arr2 = [1, 2, 3];</div><div class="line">let newArr2 = arr2.map(x =&gt; x + 1);</div></pre></td></tr></table></figure>
<p>JavaScript语言的this对象一直是一个令人头痛的问题，运行上面的代码会报错，这是因为setTimeout中的this指向的是全局对象。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">class Animal &#123;</div><div class="line">    constructor() &#123;</div><div class="line">        this.type = &apos;animal&apos;;</div><div class="line">    &#125;</div><div class="line">    says(say) &#123;</div><div class="line">        setTimeout(function() &#123;</div><div class="line">            console.log(this.type + &apos; says &apos; + say);</div><div class="line">        &#125;, 1000);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">var animal = new Animal();</div><div class="line">animal.says(&apos;hi&apos;); //undefined says hi</div></pre></td></tr></table></figure>
<p>解决办法：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">// 传统方法1: 将this传给self,再用self来指代this</div><div class="line">says(say) &#123;</div><div class="line">    var self = this;</div><div class="line">    setTimeout(function() &#123;</div><div class="line">        console.log(self.type + &apos; says &apos; + say);</div><div class="line">    &#125;, 1000);</div><div class="line">&#125;</div><div class="line"></div><div class="line">// 传统方法2: 用bind(this),即</div><div class="line">says(say) &#123;</div><div class="line">    setTimeout(function() &#123;</div><div class="line">        console.log(this.type + &apos; says &apos; + say);</div><div class="line">    &#125;.bind(this), 1000);</div><div class="line">&#125;</div><div class="line"></div><div class="line">// ES6: 箭头函数</div><div class="line">// 当我们使用箭头函数时，函数体内的this对象，就是定义时所在的对象</div><div class="line">says(say) &#123;</div><div class="line">    setTimeout(() =&gt; &#123;</div><div class="line">        console.log(this.type + &apos; says &apos; + say);</div><div class="line">    &#125;, 1000);</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="template-string-（模板字符串）"><a href="#template-string-（模板字符串）" class="headerlink" title="template string （模板字符串）"></a>template string （模板字符串）</h3><p>解决了 ES5 在字符串功能上的痛点。</p>
<p>第一个用途：字符串拼接。将表达式嵌入字符串中进行拼接，用 <code>` 和</code>${}`来界定。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">// es5</div><div class="line">var name1 = &quot;bai&quot;;</div><div class="line">console.log(&apos;hello&apos; + name1);</div><div class="line"></div><div class="line">// es6</div><div class="line">const name2 = &quot;ming&quot;;</div><div class="line">console.log(`hello$&#123;name2&#125;`);</div></pre></td></tr></table></figure>
<p>第二个用途：在ES5时我们通过反斜杠来做多行字符串拼接。ES6反引号 `` 直接搞定。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line">// es5</div><div class="line">var msg = &quot;Hi \</div><div class="line">man!&quot;;</div><div class="line"></div><div class="line">// es6</div><div class="line">const template = `&lt;div&gt;</div><div class="line">    &lt;span&gt;hello world&lt;/span&gt;</div><div class="line">&lt;/div&gt;`;</div></pre></td></tr></table></figure>
<p>另外：<code>includes</code> <code>repeat</code></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">// includes：判断是否包含然后直接返回布尔值</div><div class="line">let str = &apos;hahah&apos;;</div><div class="line">console.log(str.includes(&apos;y&apos;)); // false</div><div class="line"></div><div class="line">// repeat: 获取字符串重复n次</div><div class="line">let s = &apos;he&apos;;</div><div class="line">console.log(s.repeat(3)); // &apos;hehehe&apos;</div></pre></td></tr></table></figure>
<h3 id="destructuring-（解构）"><a href="#destructuring-（解构）" class="headerlink" title="destructuring （解构）"></a>destructuring （解构）</h3><p>简化数组和对象中信息的提取。</p>
<p>ES6前，我们一个一个获取对象信息；</p>
<p>ES6后，解构能让我们从对象或者数组里取出数据存为变量</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">// ES5</div><div class="line">var people1 = &#123;</div><div class="line">  name: &apos;bai&apos;,</div><div class="line">  age: 20,</div><div class="line">  color: [&apos;red&apos;, &apos;blue&apos;]</div><div class="line">&#125;;</div><div class="line"></div><div class="line">var myName = people1.name;</div><div class="line">var myAge = people1.age;</div><div class="line">var myColor = people1.color[0];</div><div class="line">console.log(myName + &apos;----&apos; + myAge + &apos;----&apos; + myColor);</div><div class="line"></div><div class="line">// ES6</div><div class="line">let people2 = &#123;</div><div class="line">  name: &apos;ming&apos;,</div><div class="line">  age: 20,</div><div class="line">  color: [&apos;red&apos;, &apos;blue&apos;]</div><div class="line">&#125;</div><div class="line"></div><div class="line">let &#123; name, age &#125; = people2;</div><div class="line">let [first, second] = people2.color;</div><div class="line">console.log(`$&#123;name&#125;----$&#123;age&#125;----$&#123;first&#125;`);</div></pre></td></tr></table></figure>
<h3 id="default-函数默认参数"><a href="#default-函数默认参数" class="headerlink" title="default 函数默认参数"></a>default 函数默认参数</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">// ES5 给函数定义参数默认值</div><div class="line">function foo(num) &#123;</div><div class="line">  num = num || 200;</div><div class="line">  return num;</div><div class="line">&#125;</div><div class="line"></div><div class="line">// ES6</div><div class="line">function foo(num = 200) &#123;</div><div class="line">  return num;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h3 id="rest-arguments-（rest参数）"><a href="#rest-arguments-（rest参数）" class="headerlink" title="rest arguments （rest参数）"></a>rest arguments （rest参数）</h3><p>解决了 es5 复杂的 <code>arguments</code> 问题</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">function foo(x, y, ...rest) &#123;</div><div class="line">    return ((x + y) * rest.length);</div><div class="line">&#125;</div><div class="line">foo(1, 2, &apos;hello&apos;, true, 7); // 9</div></pre></td></tr></table></figure>
<h3 id="Spread-Operator-（展开运算符）"><a href="#Spread-Operator-（展开运算符）" class="headerlink" title="Spread Operator （展开运算符）"></a>Spread Operator （展开运算符）</h3><p>第一个用途：组装数组</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">let color = [&apos;red&apos;, &apos;yellow&apos;];</div><div class="line">let colorful = [...color, &apos;green&apos;, &apos;blue&apos;];</div><div class="line">console.log(colorful); // [&quot;red&quot;, &quot;yellow&quot;, &quot;green&quot;, &quot;blue&quot;]</div></pre></td></tr></table></figure>
<p>第二个用途：获取数组除了某几项的其他项</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">let num = [1, 3, 5, 7, 9];</div><div class="line">let [first, second, ...rest] = num;</div><div class="line">console.log(rest); // [5, 7, 9]</div></pre></td></tr></table></figure>
<h3 id="对象"><a href="#对象" class="headerlink" title="对象"></a>对象</h3><p>对象初始化简写</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">// ES5</div><div class="line">function people(name, age) &#123;</div><div class="line">  return &#123;</div><div class="line">    name: name,</div><div class="line">    age: age</div><div class="line">  &#125;;</div><div class="line">&#125;</div><div class="line"></div><div class="line">// ES6</div><div class="line">function people(name, age) &#123;</div><div class="line">  return &#123;</div><div class="line">    name,</div><div class="line">    age</div><div class="line">  &#125;;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>对象字面量简写（省略冒号与 function 关键字）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">// ES5</div><div class="line">var people1 = &#123;</div><div class="line">  name: &apos;bai&apos;,</div><div class="line">  getName: function () &#123;</div><div class="line">    console.log(this.name);</div><div class="line">  &#125;</div><div class="line">&#125;;</div><div class="line"></div><div class="line">// ES6</div><div class="line">let people2 = &#123;</div><div class="line">  name: &apos;bai&apos;,</div><div class="line">  getName () &#123;</div><div class="line">    console.log(this.name);</div><div class="line">  &#125;</div><div class="line">&#125;;</div></pre></td></tr></table></figure>
<p>另外：<code>Object.assign()</code></p>
<p>ES6 对象提供了Object.assign()这个方法来实现浅复制。Object.assign()可以把任意多个源对象自身可枚举的属性拷贝给目标对象，然后返回目标对象。第一参数即为目标对象。在实际项目中，我们为了不改变源对象。一般会把目标对象传为{}</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">const obj = Object.assign(&#123;&#125;, objA, objB)</div><div class="line"></div><div class="line">// 给对象添加属性</div><div class="line">this.seller = Object.assign(&#123;&#125;, this.seller, response.data)</div></pre></td></tr></table></figure>
<h3 id="Promise"><a href="#Promise" class="headerlink" title="Promise"></a>Promise</h3><p><strong>用同步的方式去写异步代码</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div></pre></td><td class="code"><pre><div class="line">// 发起异步请求</div><div class="line">fetch(&apos;/api/todos&apos;)</div><div class="line">  .then(res =&gt; res.json())</div><div class="line">  .then(data =&gt; (&#123;</div><div class="line">    data</div><div class="line">  &#125;))</div><div class="line">  .catch(err =&gt; (&#123;</div><div class="line">    err</div><div class="line">  &#125;));</div></pre></td></tr></table></figure>
<h3 id="Generators"><a href="#Generators" class="headerlink" title="Generators"></a>Generators</h3><p>生成器（ generator）是能返回一个迭代器的函数。</p>
<p>生成器函数也是一种函数，最直观的表现就是比普通的function多了个星号<code>*</code>，在其函数体内可以使用<code>yield</code>关键字,有意思的是函数会在每个<code>yield</code>后暂停。</p>
<p>这里生活中有一个比较形象的例子。咱们到银行办理业务时候都得向大厅的机器取一张排队号。你拿到你的排队号，机器并不会自动为你再出下一张票。也就是说取票机“暂停”住了，直到下一个人再次唤起才会继续吐票。</p>
<p>迭代器：当你调用一个generator时，它将返回一个迭代器对象。这个迭代器对象拥有一个叫做next的方法来帮助你重启generator函数并得到下一个值。next方法不仅返回值，它返回的对象具有两个属性：done和value。value是你获得的值，done用来表明你的generator是否已经停止提供值。继续用刚刚取票的例子，每张排队号就是这里的value，打印票的纸是否用完就这是这里的done。</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line">// 生成器</div><div class="line">function *createIterator() &#123;</div><div class="line">  yield 1;</div><div class="line">  yield 2;</div><div class="line">  yield 3;</div><div class="line">&#125;</div><div class="line"></div><div class="line">// 生成器能像正规函数那样被调用，但会返回一个迭代器</div><div class="line">let iterator = createIterator();</div><div class="line"></div><div class="line">console.log(iterator.next().value); // 1</div><div class="line">console.log(iterator.next().value); // 2</div><div class="line">console.log(iterator.next().value); // 3</div></pre></td></tr></table></figure>
<p>迭代器对异步编程作用很大，异步调用对于我们来说是很困难的事，我们的函数并不会等待异步调用完再执行，你可能会想到用回调函数，（当然还有其他方案比如Promise比如Async/await）。</p>
<p>生成器可以让我们的代码进行等待。就不用嵌套的回调函数。使用generator可以确保当异步调用在我们的generator函数运行一下行代码之前完成时暂停函数的执行。</p>
<p>那么问题来了，咱们也不能手动一直调用next()方法，你需要一个能够调用生成器并启动迭代器的方法。就像这样子的：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div></pre></td><td class="code"><pre><div class="line">function run(taskDef) &#123;</div><div class="line">  // taskDef 即一个生成器函数</div><div class="line">  // 创建迭代器，让它在别处可用</div><div class="line">  let task = taskDef();</div><div class="line"></div><div class="line">  // 启动任务</div><div class="line">  let result = task.next();</div><div class="line"></div><div class="line">  // 递归使用函数来保持对 next() 的调用</div><div class="line">  function step() &#123;</div><div class="line">    // 如果还有更多要做的</div><div class="line">    if (!result.done) &#123;</div><div class="line">      result = task.next();</div><div class="line">      step();</div><div class="line">    &#125;</div><div class="line">  &#125;</div><div class="line"></div><div class="line">  // 开始处理过程</div><div class="line">  step();</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>以上就是 ES6 最常用的一些语法，可以说这20%的语法，在ES6的日常使用中占了80%</p>

        </div>

        <blockquote class="post-copyright">
    <div class="content">
        
<span class="post-time">
    最后更新时间：<time datetime="2017-06-24T10:52:48.965Z" itemprop="dateUpdated">2017-06-24 18:52:48</time>
</span><br>


        
        原始文章链接：<a href="/2017/06/24/es6_study/" target="_blank" rel="external">http://www.lovebxm.com/2017/06/24/es6_study/</a>
        
    </div>
    <footer>
        <a href="http://www.lovebxm.com">
            <img src="/img/avatar.jpg" alt="白小明">
            白小明
        </a>
    </footer>
</blockquote>

        
<div class="page-reward">
    <a id="rewardBtn" href="javascript:;" class="page-reward-btn waves-effect waves-circle waves-light">赏</a>
</div>



        <div class="post-footer">
            
	<ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/ECMAScript-6/">ECMAScript 6</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/JavaScript/">JavaScript</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/es6/">es6</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/js/">js</a></li></ul>


            
<div class="page-share-wrap">
    

<div class="page-share" id="pageShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.lovebxm.com/2017/06/24/es6_study/&title=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&pic=http://www.lovebxm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.lovebxm.com/2017/06/24/es6_study/&title=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&source=ES6 简介ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaS..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.lovebxm.com/2017/06/24/es6_study/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&url=http://www.lovebxm.com/2017/06/24/es6_study/&via=http://www.lovebxm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.lovebxm.com/2017/06/24/es6_study/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>



    <a href="javascript:;" id="shareFab" class="page-share-fab waves-effect waves-circle">
        <i class="icon icon-share-alt icon-lg"></i>
    </a>
</div>



        </div>
    </div>

    
<nav class="post-nav flex-row flex-justify-between">
  
    <div class="waves-block waves-effect prev">
      <a href="/2017/06/25/web-code-standards/" id="post-prev" class="post-nav-link">
        <div class="tips"><i class="icon icon-angle-left icon-lg icon-pr"></i> Prev</div>
        <h4 class="title">Web 前端代码规范</h4>
      </a>
    </div>
  

  
    <div class="waves-block waves-effect next">
      <a href="/2017/05/31/RegExp/" id="post-next" class="post-nav-link">
        <div class="tips">Next <i class="icon icon-angle-right icon-lg icon-pl"></i></div>
        <h4 class="title">最全正则表达式总结：验证QQ号、手机号、Email、中文、邮编、身份证、IP地址等</h4>
      </a>
    </div>
  
</nav>



    










    <div id="cloud-tie-wrapper" class="comments cloud-tie-wrapper"></div>
    <script>
    var cloudTieConfig = {
        url: 'http://www.lovebxm.com/2017/06/24/es6_study/index.html',
        sourceId: 'es6_study',
        productKey: '294c776acae94037bdd6605780e549e4',
        target: 'cloud-tie-wrapper',
        pcFiles: [
            '//unpkg.com/hexo-theme-material-indigo@latest/css/cloudTie/pc.css',
            '//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/pc.min.js',
        ],
        mobileFiles: [
            '//unpkg.com/hexo-theme-material-indigo@latest/css/cloudTie/mobile.css',
            '//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/mobile.min.js'
        ]
    };
    </script>
    <script src="//unpkg.com/hexo-theme-material-indigo@latest/js/cloudTie/loader.min.js"></script>







</article>

<div id="reward" class="page-modal reward-lay">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <h3 class="reward-title">
        <i class="icon icon-quote-left"></i>
        谢谢您~
        <i class="icon icon-quote-right"></i>
    </h3>
    <ul class="reward-items">
        
        <li>
            <img src="/img/wechat.jpg" title="微信打赏二维码" alt="微信打赏二维码">
            <p>微信</p>
        </li>
        

        
        <li>
            <img src="/img/alipay.jpg" title="支付宝打赏二维码" alt="支付宝打赏二维码">
            <p>支付宝</p>
        </li>
        
    </ul>
</div>



</div>

        <!-- <footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
        </p>
    </div>
    <div class="bottom">
        <p>
            <span>Power by <a href="http://hexo.io/" target="_blank">Hexo</a> Theme <a href="https://github.com/yscoder/hexo-theme-indigo" target="_blank">indigo</a></span>
            <span>白小明 &copy; 2017</span>
        </p>
    </div>
</footer> -->

<footer class="footer">
    <div class="top">
        
<p>
    <span id="busuanzi_container_site_uv" style='display:none'>
        总访客数：<span id="busuanzi_value_site_uv"></span>
    </span>
    <span id="busuanzi_container_site_pv" style='display:none'>
        总访问量：<span id="busuanzi_value_site_pv"></span>
    </span>
</p>


        <p>
            
                <span><a href="/atom.xml" target="_blank" class="rss" title="rss"><i class="icon icon-lg icon-rss"></i></a></span>
            
            <span>博客内容遵循<a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">知识共享 署名 - 非商业性 - 相同方式共享 4.0 国际协议</a></span>
            <span>白小明 &copy; 2017</span>
        </p>
    </div>
    <div class="bottom">
        <p>
        <span>
        <a target="_blank" href="mailto:80583600@qq.com" style="border-bottom:none">
        <img src="" alt="E-mail 联系" style="width:20px;height:20px;border:none;">
        </a>
        </span>

        <span>
        <a target="_blank" href="http://wpa.qq.com/msgrd?v=3&uin=80583600&site=qq&menu=yes" style="border-bottom:none">
        <img src="" title="QQ 联系" style="width:22px;height:22px;border:none;"></a>
        </span>

        <span>
        <a target="_blank" href="https://github.com/bxm0927" style="border-bottom:none">
        <img src="" alt="GitHub microzz" title="GitHub 联系" style="width:19px;height:19px;border:none;"></a>
        </span>
        </p>
    </div>
</footer>




    </main>
    <div class="mask" id="mask"></div>
<a href="javascript:;" id="gotop" class="waves-effect waves-circle waves-light"><span class="icon icon-lg icon-chevron-up"></span></a>



<div class="global-share" id="globalShare">
    <ul class="reset share-icons">
      <li>
        <a class="weibo share-sns" target="_blank" href="http://service.weibo.com/share/share.php?url=http://www.lovebxm.com/2017/06/24/es6_study/&title=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&pic=http://www.lovebxm.com/img/avatar.jpg" data-title="微博">
          <i class="icon icon-weibo"></i>
        </a>
      </li>
      <li>
        <a class="weixin share-sns wxFab" href="javascript:;" data-title="微信">
          <i class="icon icon-weixin"></i>
        </a>
      </li>
      <li>
        <a class="qq share-sns" target="_blank" href="http://connect.qq.com/widget/shareqq/index.html?url=http://www.lovebxm.com/2017/06/24/es6_study/&title=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&source=ES6 简介ECMAScript 6 简称 ES6，是 JavaScript 语言的下一代标准，已经在2015年6月正式发布了。它的目标是使得 JavaS..." data-title=" QQ">
          <i class="icon icon-qq"></i>
        </a>
      </li>
      <li>
        <a class="facebook share-sns" target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http://www.lovebxm.com/2017/06/24/es6_study/" data-title=" Facebook">
          <i class="icon icon-facebook"></i>
        </a>
      </li>
      <li>
        <a class="twitter share-sns" target="_blank" href="https://twitter.com/intent/tweet?text=《学习 ES6，一篇文章就够了》 — Xiaoming's Blog&url=http://www.lovebxm.com/2017/06/24/es6_study/&via=http://www.lovebxm.com" data-title=" Twitter">
          <i class="icon icon-twitter"></i>
        </a>
      </li>
      <li>
        <a class="google share-sns" target="_blank" href="https://plus.google.com/share?url=http://www.lovebxm.com/2017/06/24/es6_study/" data-title=" Google+">
          <i class="icon icon-google-plus"></i>
        </a>
      </li>
    </ul>
 </div>


<div class="page-modal wx-share" id="wxShare">
    <a class="close" href="javascript:;"><i class="icon icon-close"></i></a>
    <p>扫一扫，分享到微信</p>
    <img src="" alt="微信分享二维码">
</div>




    <script src="//cdn.bootcss.com/node-waves/0.7.4/waves.min.js"></script>
<script>
var BLOG = { ROOT: '/', SHARE: true, REWARD: true };



</script>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/main.min.js"></script>


<div class="search-panel" id="search-panel">
    <ul class="search-result" id="search-result"></ul>
</div>
<template id="search-tpl">
<li class="item">
    <a href="{path}" class="waves-block waves-effect">
        <div class="title ellipsis" title="{title}">{title}</div>
        <div class="flex-row flex-middle">
            <div class="tags ellipsis">
                {tags}
            </div>
            <time class="flex-col time">{date}</time>
        </div>
    </a>
</li>
</template>

<script src="//unpkg.com/hexo-theme-material-indigo@latest/js/search.min.js" async></script>






<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>



<script>
(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = '死鬼去哪里了！';
            clearTimeout(titleTime);
        } else {
            document.title = '(つェ⊂)咦!又好了!';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },2000);
        }
    });
})();
</script>



</body>
</html>
